// 调试工具 - 用于测试游客登录
import { guestService } from './services/guestService';

// 将调试函数挂载到全局对象上，方便在浏览器控制台中调用
declare global {
  interface Window {
    debugGuestLogin: () => Promise<void>;
    debugUserStore: () => void;
  }
}

window.debugGuestLogin = async () => {
  console.log('手动触发游客登录...');
  try {
    const result = await guestService.autoLoginAsGuest();
    console.log('游客登录结果:', result);
  } catch (error) {
    console.error('游客登录错误:', error);
  }
};

window.debugUserStore = () => {
  const { useUserStore } = require('./stores');
  const userStore = useUserStore();
  console.log('用户存储状态:', {
    token: userStore.token,
    userInfo: userStore.userInfo,
    isGuestMode: userStore.isGuestMode,
    isGuest: guestService.isGuest()
  });
};

console.log('调试工具已加载，可以在控制台中调用:');
console.log('- window.debugGuestLogin() // 手动触发游客登录');
console.log('- window.debugUserStore() // 查看用户存储状态');
